<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    // 获取虚拟目录
    String path = request.getContextPath();
    // url:               协议                       主机                        端口号             虚拟目录
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>内容显示区</title>
    <!-- 1. 导入CSS的全局样式 -->
    <link href="<%=path%>/CSS/bootstrap.min.css" rel="stylesheet">
    <!-- 2. jQuery导入，建议使用1.9以上的版本 -->
    <script src="<%=path%>/js/jquery-2.1.0.min.js"></script>
    <!-- 3. 导入bootstrap的js文件 -->
    <script src="<%=path%>/js/bootstrap.min.js"></script>

    <script>
        function deleteN(id) {
            if (confirm("您确定要删除吗？")){
                location.href="delP?id="+id;
            }
        }
        function tiaoz() {
            var val = $("#searchq").val();
            location.href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage="+val;
        }
    </script>
</head>
<body>
<div class="table-responsive" style="float:right;width: 680px;height:500px;">
    <div class="col-lg-5" style="float: right;margin-top: 20px">
        <div class="input-group">
            <input type="text" class="form-control" placeholder="请输入页码" title="跳转到第XXX页" data-toggle="tooltip" data-placement="bottom" id="searchq">
            <span class="input-group-btn">
        <button class="btn btn-default" type="button" id="gop" onclick="tiaoz();">Go!</button>
      </span>
        </div>
    </div>
    <table class="table table-hover" style="float:right;width: 680px;height:300px;">
        <thead>
        <tr>
            <th>#ID</th>
            <th>新闻人物</th>
            <th>住址</th>
            <th>得票数</th>
            <th>职业</th>
            <th>删除/修改</th>
        </tr>
        </thead>
        <tbody>
        <C:forEach items="${pb.list}" var="pb" varStatus="s">
            <tr>
                <th scope="row">${pb.id}</th>
                <td><a href="indexServlet?method=person&strid=${pb.id}">${pb.people_name}</a></td>
                <td>${pb.people_address}</td>
                <td>${pb.people_number}</td>
                <td>${pb.people_job}</td>
                <td><a href="javascript:deleteN(${pb.id});">删除</a>/<a href="http://localhost:8080/news_war_exploded/findidp?id=${pb.id}">修改</a></td>
            </tr>
        </C:forEach>
        </tbody>
    </table>

    <center>
        <nav style="float: right">
            <ul class="pagination">
                <li title="点击此处可快速返回第一页"><a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=1">首页</a></li>
                <c:if test="${pb.currentPage == 1}">
                    <li class="disabled" title="上一页">
                </c:if>
                <c:if test="${pb.currentPage != 1}">
                    <li title="上一页">
                </c:if>
                    <a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=${pb.currentPage - 1}"
                       aria-label="Previous">
                        <span aria-hidden="true">&laquo;</span>
                    </a>
                </li>

                <c:forEach begin="1" end="${pb.countPage}" var="i">
                    <c:if test="${pb.currentPage ==  i}">
                        <li class="active"><a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=${i}">${i}</a></li>
                    </c:if>
                    <c:if test="${pb.currentPage !=  i}">
                        <li><a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=${i}">${i}</a></li>
                    </c:if>
                </c:forEach>

                <c:if test="${pb.currentPage == pb.countPage}">
                    <li class="disabled" title="下一页">
                </c:if>
                <c:if test="${pb.currentPage != pb.countPage}">
                    <li title="下一页">
                </c:if>
                    <a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=${pb.currentPage + 1}"
                       aria-label="Next">
                        <span aria-hidden="true">&raquo;</span>
                    </a>
                </li>
                <li title="点击此处可快速定位到最后一页"><a href="${pageContext.request.contextPath}/pageperson?rows=2&currentPage=${pb.countPage}">尾页</a></li>
            </ul>
        </nav>
    </center>
    <p style="float: left">共${pb.totalPage}条记录，共${pb.countPage}页，当前您在第${pb.currentPage}页，每页显示${pb.rows}条数据</p>
</div>
</body>
</html>